package com.zbkj.admin.controller.mszs;

import com.zbkj.common.model.mszs.MszsQimoReceivekey;
import com.zbkj.common.page.CommonPage;
import com.zbkj.common.request.PageParamRequest;
import com.zbkj.common.request.mszs.MszsQimoReceivekeyRequest;
import com.zbkj.common.request.mszs.MszsQimoReceivekeySelectRequest;
import com.zbkj.common.response.CommonResult;
import com.zbkj.common.response.mszs.MszsQimoReceivekeyResponse;
import com.zbkj.service.service.mszs.MszsQimoReceivekeyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @description 民宿助手接收七陌按键-controller层
 * @author lijie
 * @date 2023-11-16
 */
@RestController
@RequestMapping(value = "api/admin/mszs/qimo/receivekey")
@Slf4j
@Api(tags = "民宿助手-接收七陌按键信息")
public class MszsQimoReceivekeyController {

    @Autowired
    private MszsQimoReceivekeyService qimoReceivekeyService;

    @PreAuthorize("hasAuthority('admin:mszs:receivekey:insert')")
    @ApiOperation(value="新增-接受七陌按键信息")
    @RequestMapping(value = "/insert",method = RequestMethod.POST)
    public CommonResult<Boolean> insert(@RequestBody @Validated MszsQimoReceivekeyRequest request){
        return CommonResult.success(qimoReceivekeyService.insert(request));
    }

    @PreAuthorize("hasAuthority('admin:mszs:receivekey:delete')")
    @ApiOperation(value="刪除-根据id标识删除")
    @RequestMapping(value = "/delete", method = RequestMethod.GET)
    @ApiImplicitParam(name = "id", value = "主键id标识",required = true)
    public CommonResult<Boolean> delete(@RequestParam("id")int id){
        return CommonResult.success(qimoReceivekeyService.delete(id));
    }

    @PreAuthorize("hasAuthority('admin:mszs:receivekey:update')")
    @ApiOperation(value="更新")
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public CommonResult<Boolean> update(@RequestBody @Validated MszsQimoReceivekeyRequest request){
        return CommonResult.success(qimoReceivekeyService.update(request));
    }

    @PreAuthorize("hasAuthority('admin:mszs:receivekey:load')")
    @ApiOperation(value="查询-根据主键id查询")
    @RequestMapping(value = "/load", method = RequestMethod.GET)
    @ApiImplicitParam(name = "id", value = "主键id标识",required = true)
    public CommonResult<MszsQimoReceivekeyResponse> load(@RequestParam("id") int id){
        return CommonResult.success(qimoReceivekeyService.load(id));
    }

    @PreAuthorize("hasAuthority('admin:mszs:receivekey:pageList')")
    @ApiOperation(value="查询-分页查询")
    @RequestMapping(value = "/pageList", method = RequestMethod.GET)
    public CommonResult<CommonPage<MszsQimoReceivekey>> pageList(
            @Validated MszsQimoReceivekeySelectRequest request,
            @Validated PageParamRequest pageParamRequest) {
        CommonPage<MszsQimoReceivekey> mszsOrderPage = CommonPage.restPage(qimoReceivekeyService.pageList(request,pageParamRequest));
        return CommonResult.success(mszsOrderPage);
    }
}
